package com.atwj.dao.impl;

import com.atwj.dao.UserDao;
import com.atwj.entity.User;

/**
 * @author 吴先森
 * @description:
 * @create 2022-03-17 19:21
 */
public class UserDaoImpl extends baseDao implements UserDao {
    @Override
    public User queryUserByUsername(String username) {
        String sql = "select `id`,`username`,`password`,`email` from t_user where username = ?";
        return queryForOne(User.class, sql, username);
    }

    @Override
    public User queryUserByUsernameAndPassword(String username, String password) {
        String sql = "select id,username,password,email from t_user where username = ? and password = ?";
        return queryForOne(User.class, sql, username, password);
    }

    @Override
    public int SaveUser(User user) {
        String sql = "insert into t_user(id,username,password,email)values(?,?,?,?)";
        return update(sql, user.getId(), user.getUsername(), user.getPassword(), user.getEmail());
    }
}
